{% extends "admin.html" %}


{% block jsfuncs %}

$('save_options').addEvent('submit', function(e) {
	new Event(e).stop();
	
	var log = $('load_img').setStyles({'display':'inline'});
   this.set('send',{
		encoding: 'utf-8',
		evalScripts: true,
		onComplete: function() {
			log.setStyles({'display':'none'});
		}
	});
   this.send();
});

$('clear_cache').addEvent('click', function(e) {
	new Event(e).stop();
	
	var log = $('load_img_reset').setStyles({'display':'inline'});
   
	var req = new Request.HTML({ 	url: '/admin/cache/del',
	 									  	method: 'post',
										  	evalScripts : true,
										  	data: 'action=del_cache',
											onComplete: function(e) {
												log.setStyles({'display':'none'});
											}
										}).send();
	return false;
});

$('check_opt').addEvent('click', function(e) {
	new Event(e).stop();
	
	var log = $('load_img_check').setStyles({'display':'inline'});
   
var req = new Request.HTML({ 	url: '/admin/options/check',
	 									  	method: 'post',
										  	evalScripts : true,
										  	data: 'action=update_opts',
											onComplete: function(e) {
												log.setStyles({'display':'none'});
											}
										}).send();
  return false;
});

{% endblock %}

{% block menu2 %}
<div id="menu2">
	<ul>
		<li{% if global_options %} class="current"{% endif %}><a href="/admin/options/">设置</a></li>
		<li{% if cached_pages %} class="current"{% endif %}><a href="/admin/options/cache/">缓存页面</a></li>
	</ul>
</div>
{% endblock %}

{% block content %}

<form id="save_options" action="/admin/options/" method="post">
<table id="options_table">
{% for opt in global_options %}
<tr><td class="option_name"><label>{{ opt.label }}:</label></td>
	<td class="option_value">
<!--	<input type="text" name="{{opt.name}}" value="{{opt.value}}" id="{{opt.name}}" />
	-->
	{{ opt.html }}</td>
</tr>
{% endfor %}
<!--<tr><td class="option_name"><label>permission user:</label></td><td class="option_value"><input type="text" name="permission" value="{{user}}" id="permission" /></td></tr>
-->
<tr><td class="option_name"><input type="submit" value="保存"></td><td><img src="/static/images/loading.gif" style="display:none;" id="load_img" /></td></tr>
<tr><td class="option_name reset_button"><a href="#" id="clear_cache">清除所有缓存</a></td><td><img src="/static/images/loading.gif" style="display:none;" id="load_img_reset" /></td></tr>
<tr><td class="option_name reset_button"><a href="#" id="check_opt">检查设置选项</a></td><td><img src="/static/images/loading.gif" style="display:none;" id="load_img_check" /></td></tr>
</table>

</form>


{% endblock %}